package com.snopy.stream;

import lombok.extern.slf4j.Slf4j;

import java.io.*;

/**
 * @author snopy
 * @version 1.0.0
 * @classname CopyBytes
 * @description
 * @email 77912204@qq.com
 * @date 2022/07/29 15:04
 */
@Slf4j
public class CopyBytes {

    public static void main(String[] args) {
        FileInputStream in = null;
        FileOutputStream out = null;
        try {
            in = new FileInputStream("Sonata_java8/src/main/resources/xanadu.txt");
            out = new FileOutputStream("Sonata_java8/src/main/resources/outagain.txt");
            byte c;
            while ((c=(byte) in.read())!=-1){
                out.write((int)c);
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }finally {
            if (in!=null){
                try {
                    in.close();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            if (out!=null){
                try {
                    out.close();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        }
    }
}
